package com.cstar.learnlang.PageControllers;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

import com.cstar.learnlang.DataForms.PasswordResetDataForm;

@Controller
@RequestMapping(value={"/otherPages/passwordResetPost", "/otherPages/passwordResetPage"})
@SessionAttributes
public class PasswordResetPageController {
	@Autowired
	private HomePageController homePageController;
	private static final Logger logger = LoggerFactory.getLogger(PasswordResetPageController.class);
	@RequestMapping(value = "/otherPages/passwordResetPage", method = RequestMethod.GET)
	public String passwordResetPage(HttpServletRequest request,
			HttpServletResponse response,
    		HttpSession session,
			@RequestParam(value="logout", required=false) String logout, 
			@RequestParam(value="ln", required=false) String ln) {
		homePageController.ProcessLanguageSwitchAndLogout(request, response, session, ln, logout);
		logger.info("passwordResetPage");
		session.setAttribute("pageName", "passwordReset");
		return "otherPages/passwordResetPage";
	}
	@RequestMapping(value="/otherPages/passwordResetPost", method = RequestMethod.POST)
    public String loginAction(@ModelAttribute("passwordResetInfo") PasswordResetDataForm passwordResetInfo, BindingResult result) {
        System.out.println("email:" + passwordResetInfo.getEmail());
        return "redirect:/homePage";
    }
	@ModelAttribute("passwordResetInfo")
    public PasswordResetDataForm getPasswordResetObj() {
        return new PasswordResetDataForm();
    }
} // PasswordResetPageController
